home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / cwktask.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  20KB  |  733 lines

  1.  
  2.  
  3. /*
  4.     GWMON Parallel Ada Monitor for 386/486 PCs   
  5.     Copyright (C) 1993, Charles W. Kann  & Michael Bliss Feldman
  6.                         ckann@seas.gwu.edu mfeldman@seas.gwu.edu
  7.  
  8.     This program is free software; you can redistribute it and/or modify
  9.     it under the terms of the GNU General Public License as published by
  10.     the Free Software Foundation; either version 2 of the License.
  11.  
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21. */
  22.  
  23. #include "ed.h"
  24. #include "keydef.h"
  25. /*
  26.     I need the variable "exception_trace" from ivars.h.  I don't want
  27.     to use the whole .h, so I am including this one variable here.
  28. */
  29. extern int exception_trace;
  30.  
  31. static int current_task;
  32. static int save_block_number = -1;
  33. static long Run_Current_Time; /* Run time (lines) since last report */
  34. extern rr_flag;
  35. void CWK_SET_TASK();
  36. void CWK_SET_TASK_LINE();
  37. void CWK_GET_KEY();
  38. static void scroll_tasks();
  39.  
  40. void busy_wait(wait_cnt)
  41. int wait_cnt;
  42. {
  43.     int i, cycles;
  44.     cycles = delay_scaling_factor * delay_array[wait_cnt];
  45.     for ( i = 0; i < cycles; ++i );
  46. }
  47.  
  48. void CWK_CREATE_TASK(task_no, task_name, task_file)
  49. int task_no;
  50. char *task_name;
  51. char *task_file;
  52. {
  53.     char msg[100];
  54.     int ch;
  55.  
  56.     if ( task_no > MAX_TSKS ) {
  57.     printf("Can't work with more than %d tasks...", MAX_TSKS-1);
  58.     }
  59.     /*
  60.     Find the task particulars in the task file (For now, hard code them)
  61.     */
  62.     CWK_TASKS[task_no].TN = malloc( strlen(task_name)+1 );
  63.     strcpy( CWK_TASKS[task_no].TN, task_name );
  64.     CWK_TASKS[task_no].FL = 1;
  65.     CWK_TASKS[task_no].LL = 10000;
  66.     CWK_TASKS[task_no].FLOS = 0;
  67.     CWK_TASKS[task_no].CL = 0;
  68.     CWK_TASKS[task_no].MON = CWK_CREATE_MON_WIN(CWK_TASKS[task_no].TN, 
  69.         (monitor_type == 1) ? 1 : 0 );
  70.         CWK_TASKS[task_no].FD = CWK_LOAD_FILE(task_file);
  71. }
  72.  
  73. /*************************************************************************/
  74. /*                                     */
  75. /*    CWK_Switch_Block is used to make sure the correct program block  */
  76. /*    (ie procedure, package, task, etc) is being used.  When a program*/
  77. /*    block becomes current, we want to make sure that we then move to */
  78. /*    use that program block.  Program blocks are entered and exited   */
  79. /*    inta.c.  We call this routine from there.             */
  80. /*                                     */
  81. /*    parameters:                             */
  82. /*        block_number : the block number of this block           */
  83. /*        block_name   : the title of the block (ie proc name)     */
  84. /*        block_file   : file which contains this block            */
  85. /*         enter_or_exit: Are we entering or exiting this block     */
  86. /*                   This is only used in procedure monitoring */
  87. /*                   If this is 1 - exiting, 0 - entering     */
  88. /*                                     */
  89. /*************************************************************************/
  90.  
  91. CWK_Switch_Block( block_number, block_name, block_package, block_file, 
  92.           enter_or_exit )
  93. int block_number, enter_or_exit;
  94. char *block_name, *block_package, *block_file;
  95. {
  96.     FILE_REC_PTR Save_FD;
  97.     char package_routine[68];
  98.  
  99.     /*
  100.         In the case of task monitoring, if the new procedure is in
  101.         a different source file from the one currently being used,
  102.         move to that source file.
  103.     */ 
  104.     
  105.     if ( task_monitor )
  106.     {
  107.             Save_FD = CWK_TASKS[current_task].FD;
  108.             CWK_TASKS[current_task].FD = CWK_LOAD_FILE(block_file);
  109.             if ( Save_FD != CWK_TASKS[current_task].FD )
  110.                     CWK_TASKS[current_task].FLOS = 0;
  111.     }
  112.  
  113.     /*
  114.         Procedure monitoring
  115.     */
  116.     else
  117.     {
  118.         /*
  119.             The save_block_number remembers the block between
  120.             calls.  The first time through, however, it must be set
  121.         */
  122.         if ( save_block_number == -1 )
  123.             save_block_number = block_number;
  124.  
  125.         /*
  126.             If this block hasn't been created, and we have a valid
  127.             block, create it.  If the block is part of a package,
  128.             prepend the package name.
  129.         */
  130.  
  131.         if ( strcmp( block_package, "main" ) != 0 )
  132.         {
  133.                 strcpy( package_routine, block_package );
  134.                 strcat( package_routine, "." );
  135.                 strcat( package_routine, block_name );
  136.         }
  137.         else
  138.                 strcpy( package_routine, block_name );
  139.  
  140.         if  ( CWK_BLKS[block_number].MON == NULL ) 
  141.             CWK_CREATE_BLOCK(block_number, package_routine, 
  142.                      block_file );
  143.  
  144.         /*
  145.             Only worry about monitor windows if the monitor is
  146.             running.
  147.         */
  148.  
  149.         if ( monitor_type != 1 )
  150.             return;
  151.         
  152.         if ( monitor_window_type == 3 )
  153.         {
  154.             save_block_number = block_number;
  155.             CWK_DRAW_PROC_WIN( CWK_BLKS[block_number].MON, 
  156.                 enter_or_exit );
  157.  
  158.                 CWK_BLKS[save_block_number].FLOS = 0;
  159. #if 0
  160.             CWK_SET_TASK_LINE( CWK_BLKS[block_number].CL, 0 );
  161. #endif
  162.  
  163.             /*
  164.                 If the mode is to be in task step mode,
  165.                 then wait for a key to be pressed to
  166.                 move to the next step, otherwise, wait
  167.                 a second to keep the screen from flashing.
  168.             */
  169.  
  170.             if ( task_step )
  171.                      CWK_GET_KEY( 1 );
  172.             else
  173.                 busy_wait( MAX_DELAY-1 );
  174.         }
  175.         else
  176.             save_block_number = block_number;
  177.             
  178.     }
  179. }
  180.  
  181. CWK_LEAVE_BLOCK( block_number )
  182. int block_number;
  183. {
  184.     if ( monitor_type != 1 )
  185.         return;
  186.     if ( ! task_monitor )
  187.         CWK_REMOVE_BLOCK( CWK_BLKS[block_number].MON);
  188. }
  189.  
  190. /*************************************************************************/
  191. /*************************************************************************/
  192.     
  193. void CWK_DISTROY_TASK(task_no)
  194. int task_no;
  195. {
  196.     CWK_TASKS[task_no].TN = "";
  197.     CWK_TASKS[task_no].FL = 0;
  198.     CWK_TASKS[task_no].LL = 0;
  199.     CWK_DEL_MON_WIN(CWK_TASKS[task_no].MON);
  200. }
  201.     
  202. void CWK_CHANGE_TASK_STAT(task_no, stat, task_name, task_file )
  203. int task_no;
  204. char stat;
  205. char *task_name, *task_file;
  206. {
  207.     int FLOS;
  208.     FLOS = CWK_TASKS[task_no].FLOS;
  209.  
  210.     if ( ! task_monitor )
  211.         return;
  212.  
  213.     CWK_TASKS[task_no].ST = stat;
  214.  
  215.     switch( stat ) {
  216.         case 'C' :      /* Create a new task */
  217.         CWK_CREATE_TASK( task_no, task_name, task_file );
  218.         CWK_TASKS[task_no].ST = '*';
  219.         break;
  220.         case 'A' :     /* Activate a task */
  221.         CWK_SET_TASK( task_no );
  222.         CWK_TASKS[task_no].ST = '*';
  223.         if ( ( task_step ) && ( CWK_TASKS[task_no].MON->WON == 1 ) )
  224.                  CWK_GET_KEY( 1 );
  225.         break;
  226.         case 'S' :    /* Change to a new task */
  227.         CWK_SET_TASK( task_no );
  228.         CWK_TASKS[task_no].ST = '*';
  229.         break;
  230.         case 'D' :    /* Delaying task       */
  231.         if ( monitor_type == 1 )
  232.         {
  233.             CWK_CUR_LINE( CWK_TASKS[task_no].MON, 
  234.                 CWK_TASKS[task_no].CL- FLOS, " D " );
  235.             if ( ( task_step ) && 
  236.                  ( CWK_TASKS[task_no].MON->WON == 1 ) )
  237.                      CWK_GET_KEY( 1 );
  238.         }
  239.         break;
  240.         case 'R' :    /* Waiting Rendezvous  */
  241.         if ( monitor_type == 1 )
  242.         {
  243.             CWK_CUR_LINE( CWK_TASKS[task_no].MON,
  244.                 CWK_TASKS[task_no].CL- FLOS, " R " );
  245.             if ( ( task_step ) && 
  246.                  ( CWK_TASKS[task_no].MON->WON == 1 ) )
  247.                      CWK_GET_KEY( 1 );
  248.         }
  249.         break;
  250.         case 'M' :    /* Rendezvous Met  */
  251.         if ( monitor_type == 1 )
  252.         {
  253.             CWK_CUR_LINE( CWK_TASKS[task_no].MON,
  254.                 CWK_TASKS[task_no].CL- FLOS, " M " );
  255.             if ( ( task_step ) && 
  256.                  ( CWK_TASKS[task_no].MON->WON == 1 ) )
  257.                      CWK_GET_KEY( 1 );
  258.         }
  259.         break;
  260.         case 'E' :    /* Rendezvous Met  */
  261.         CWK_DISTROY_TASK( task_no );
  262.         break;
  263.         }
  264. }
  265.  
  266. void CWK_SET_TASK_LINE( line_no, getkey_or_not )
  267. int line_no, getkey_or_not;
  268. {
  269.     int i;
  270.     int FLOS;
  271.     static text_string[50], format_string[50];
  272.  
  273.     TASK_REC *temp_task;
  274.     int task_no;
  275.  
  276.     if ( task_monitor )
  277.     {
  278.         task_no = current_task;
  279.         temp_task = CWK_TASKS;
  280.     }
  281.     else
  282.     {
  283.         task_no = save_block_number;
  284.         temp_task = CWK_BLKS;
  285.     }
  286.  
  287.         if ( temp_task[task_no].FD->lines_in_file < line_no )
  288.     {
  289.         return;
  290.     }
  291.  
  292.     if ( ( temp_task[task_no].MON->WON != 1 )  ||
  293.          ( monitor_type != 1 ) )
  294.     {
  295.         return;
  296.     }
  297.  
  298.     FLOS = temp_task[task_no].FLOS;
  299.     if ( FLOS != 0 ) 
  300.         CWK_CUR_LINE(temp_task[task_no].MON, 
  301.            temp_task[task_no].CL - FLOS, "   ");
  302.     if (( FLOS == 0 ) ||
  303.        (( line_no < FLOS ) || (line_no > FLOS + WIN_SIZE))) {
  304.         FLOS = line_no - (WIN_SIZE / 2);
  305.         if (FLOS < 1) 
  306.             FLOS = 1;
  307.         temp_task[task_no].FLOS = FLOS;
  308.         for ( i = 0; i < WIN_SIZE; ++i )
  309.             {
  310.             /*   Blank out the current line                     */
  311.  
  312.                 CWK_CUR_LINE(temp_task[task_no].MON, i+1, "   ");
  313.             sprintf( format_string,"%c%d.%ds", '%', 
  314.                 LINE_SIZE+4-Block_Level,
  315.                 LINE_SIZE+4-Block_Level );
  316.             sprintf( text_string, format_string, " " );
  317.              CWK_WRITE_LINE(temp_task[task_no].MON, i+1,  
  318.                 text_string );
  319. #if 0
  320.             if ( ( monitor_window_type == 0 ) || 
  321.                  ( monitor_window_type == 2 ) )
  322.                  CWK_WRITE_LINE(temp_task[task_no].MON, i+1, 
  323.                 "                                " );
  324.             else
  325.                  CWK_WRITE_LINE(temp_task[task_no].MON, i+1, 
  326.                 "                                                                    " );
  327.  
  328. #endif
  329.             /* Stop putting out lines when you have reached */
  330.             /* the end of the file so you don't access bad  */
  331.             /* memory                                       */
  332.  
  333.                 if (temp_task[task_no].FD->lines_in_file < 
  334.                     FLOS+i)
  335.             {
  336.                 continue;
  337.             }
  338.  
  339.             /* Now write out the line to the screen.  Note that */
  340.             /* the use of different window types was stuffed in */
  341.             /* later int he program life, and so the string size*/
  342.             /* for a window is handled here, not in cwkgraph    */
  343.             /* where it belongs!                    */
  344.  
  345.             sprintf( format_string,"%c3.3d %c-%d.%ds", '%', '%', 
  346.                 LINE_SIZE-Block_Level, LINE_SIZE-Block_Level );
  347.             sprintf( text_string, format_string, FLOS+i,
  348.                     temp_task[task_no].FD->lines[FLOS+i]);
  349. #if 0
  350.             if ( ( monitor_window_type == 0 ) || 
  351.                  ( monitor_window_type == 2 ) )
  352.                 sprintf( text_string, "%3.3d %-28.28s", FLOS+i,
  353.                     temp_task[task_no].FD->lines[FLOS+i]);
  354.             else
  355.                 sprintf( text_string, "%3.3d %-68.68s", FLOS+i,
  356.                     temp_task[task_no].FD->lines[FLOS+i]);
  357. #endif
  358.              CWK_WRITE_LINE(temp_task[task_no].MON, i+1, 
  359.                     text_string);
  360.             }
  361.         }
  362.     
  363.     temp_task[task_no].CL = line_no;
  364.     CWK_CUR_LINE(temp_task[task_no].MON, line_no - FLOS, "-->");
  365.  
  366.     if ( getkey_or_not )
  367.         CWK_GET_KEY( 0 );
  368. }
  369.  
  370. void CWK_SET_TASK(task_no)
  371. int task_no;
  372. {
  373.     int ch;
  374.  
  375.     current_task = task_no;
  376. }
  377.  
  378. /***********************************************************************/
  379. /* This section of code handles the control screen .                   */
  380. /***********************************************************************/
  381.  
  382. void print_status()
  383. {
  384.     int iline;
  385.     int save_current_task;
  386.  
  387.     if ( rr_flag )
  388.             CWK_CONTROL_TASK( "Round Robin", CWK_TASKS[current_task].TN,
  389.         Run_Total_Time, 0 );
  390.     else
  391.             CWK_CONTROL_TASK( "Run til blk", CWK_TASKS[current_task].TN,
  392.         Run_Total_Time, 0 );
  393.     scroll_tasks();
  394.     CWK_ERASE_ALL_MON_WIN();
  395.     
  396.     /*    
  397.         Save the current task.  This is because I want to use the
  398.         routine CWK_SET_TASK_LINE to redraw the windows.  It requires
  399.         current_task to be the task redrawn.  So I set it in the loop,
  400.         and at the end restore the value.
  401.     */
  402.  
  403.     save_current_task = current_task;
  404.     for ( iline = 0; iline < MAX_TSKS; ++iline ) {
  405.         if ( CWK_TASKS[iline].TN != NULL ) {
  406. #if 0
  407.             CWK_TASKS[iline].Cur_Time = 0;
  408. #endif
  409.             if ( CWK_TASKS[iline].MON->WON == 1 ) {
  410.                 current_task = iline;
  411.                 CWK_DRAW_MON_WIN( CWK_TASKS[iline].MON );
  412.                 CWK_TASKS[iline].FLOS = 0;
  413.                 CWK_SET_TASK_LINE( CWK_TASKS[iline].CL, 0 );
  414.             }
  415.             else 
  416.                 CWK_TASKS[iline].MON->WON = -1;
  417.         }
  418.     }
  419.     current_task = save_current_task;
  420. }
  421.  
  422. #define START_LINE 4
  423. #define LINES 8
  424. static void scroll_tasks()
  425. {
  426.     int ch, iline, cur_task, Active_Tasks = 0;
  427.     int stay_flag;
  428.     char msg[100];
  429.     int First_Task_On_Screen = 1;
  430.  
  431.       sprintf( msg,"Task #   Task Type        File           Line #   Stat WON  Exe %1.1c", '%');
  432.         CWK_PRINT_CONTROL_LINE( START_LINE - 1, msg );
  433.  
  434.     Active_Tasks = print_control_lines( First_Task_On_Screen );
  435.     
  436.  
  437.     iline = START_LINE;
  438.         CWK_PRINT_CONTROL_LINE(iline, "->");
  439.     stay_flag = 1;
  440.     while (stay_flag) {
  441.         ch = getch();
  442.         switch (ch ) {
  443.             case UPARROW : 
  444.                 CWK_PRINT_CONTROL_LINE(iline, "  ");
  445.             if ( --iline < START_LINE ) {
  446.              if ( First_Task_On_Screen != 1 ) {
  447.                 First_Task_On_Screen -= (LINES - 1);
  448.                 Active_Tasks = print_control_lines( First_Task_On_Screen );
  449.             }
  450.             iline = START_LINE;
  451.             }
  452.                 CWK_PRINT_CONTROL_LINE(iline, "->");
  453.             break;
  454.             case DOWNARROW : 
  455.                 CWK_PRINT_CONTROL_LINE(iline, "  ");
  456.             if ( ++iline >= (START_LINE + Active_Tasks) ) {
  457.             if ( iline <= LINES + START_LINE - 1 )
  458.                 iline = START_LINE + Active_Tasks - 1;
  459.             else {
  460.                 First_Task_On_Screen += (LINES - 1);
  461.                 Active_Tasks = print_control_lines( First_Task_On_Screen );
  462.                 iline = START_LINE;
  463.             }
  464.             }
  465.                 CWK_PRINT_CONTROL_LINE(iline, "->");
  466.             break;
  467.         case 't' :
  468.         case 'T' :
  469.             cur_task = iline - START_LINE + First_Task_On_Screen;
  470.             if ( CWK_TASKS[cur_task].MON->WON == 1 )
  471.             CWK_TASKS[cur_task].MON->WON = -1;
  472.             else if (( CWK_TASKS[cur_task].MON->WON == 0 ) || 
  473.                     ( CWK_TASKS[cur_task].MON->WON == -1 ) )
  474.             CWK_TASKS[cur_task].MON->WON = 1;
  475.             sprintf( msg, "-> %2.2d     %-15.15s  %-15.15s %4d     %1.1c    %-3.3s  %3.2f  ", 
  476.                 cur_task, CWK_TASKS[cur_task].TN, 
  477.                 CWK_TASKS[cur_task].FD->FN,
  478.                 CWK_TASKS[cur_task].CL,
  479.                 CWK_TASKS[cur_task].ST, 
  480.                 ( CWK_TASKS[cur_task].MON->WON == 1) ? "yes" : "no",
  481.                 (float) CWK_TASKS[cur_task].Cur_Time /
  482.                 (float)Run_Current_Time );
  483.             
  484.                 CWK_PRINT_CONTROL_LINE(iline, msg);
  485.             break;
  486.         case ESC :
  487.             stay_flag = 0;
  488.             break;
  489.         default : 
  490.             break;
  491.         }
  492.     }
  493.     CWK_DEL_CONTROL();
  494. }
  495.  
  496. int
  497. print_control_lines( First_Task_On_Screen )
  498. int First_Task_On_Screen;
  499. {
  500.     int iline, Active_Tasks = 0;
  501.     char msg[80];
  502.  
  503.     for ( iline=START_LINE; iline < LINES + START_LINE; ++iline ){
  504.         sprintf( msg, "%67s", " ");
  505.         CWK_PRINT_CONTROL_LINE( iline, msg );
  506.     }
  507.  
  508.     for ( iline=First_Task_On_Screen; 
  509.           iline < MAX_TSKS  && (iline - First_Task_On_Screen) < LINES; 
  510.           iline++ )
  511.     {
  512.         if ( CWK_TASKS[iline].TN == NULL )
  513.             continue;
  514.         Active_Tasks++;
  515.         sprintf( msg, "   %2.2d     %-15.15s  %-15.15s %4d     %1.1c    %-3.3s  %3.2f  ", 
  516.             iline, CWK_TASKS[iline].TN, 
  517.             CWK_TASKS[iline].FD->FN,
  518.             CWK_TASKS[iline].CL,
  519.             CWK_TASKS[iline].ST, 
  520.             ( CWK_TASKS[iline].MON->WON == 1) ? "yes" : "no",
  521.             (float) CWK_TASKS[iline].Cur_Time /
  522.                 (float)Run_Current_Time );
  523.             CWK_PRINT_CONTROL_LINE( iline+START_LINE-First_Task_On_Screen,
  524.                      msg );
  525.     }
  526.     return Active_Tasks;
  527. }
  528. #undef LINES
  529. #undef START_LINE
  530. /***********************************************************************/
  531.  
  532.  
  533. void CWK_GET_KEY( other_stop )
  534. int other_stop;
  535. {
  536.     int ch = 0;
  537.  
  538.     if ( other_stop == -1 ) {
  539.         if (kbhit()) {
  540.             ch = getch();
  541.             }
  542.         }
  543.     else if ( ( step_monitor )  || ( other_stop ) ){
  544.         ch = getch();
  545.         }
  546.     else if (kbhit()) {
  547.         ch = getch();
  548.         }
  549.  
  550.     if ( ch != 0 ) {
  551.         switch ( ch ) {
  552.         case CTRL_L :
  553.             step_monitor = ++step_monitor % 2;
  554.             break;
  555.         case UPARROW :
  556.             step_rate--;
  557.             if ( step_rate < 0 )
  558.             step_rate = 0;
  559.             break;
  560.         case DOWNARROW :
  561.             step_rate++;
  562.             if ( step_rate >= MAX_DELAY )
  563.             step_rate = MAX_DELAY - 1;
  564.             break;
  565.             case CTRL_A :
  566.             print_status();
  567.             break;
  568.             case CTRL_B :
  569.             CWK_STOP_MONITORING();
  570.             break;
  571.             case CTRL_D :
  572.             case F10 :
  573.             if ( task_monitor ) 
  574.                 CWK_TASK_SETUP();
  575.             else
  576.                 CWK_SEQ_SETUP();
  577.             break;
  578.             case CTRL_H :
  579.             print_help();
  580.             break;
  581.             case CTRL_K :
  582.             print_license();
  583.             break;
  584.             case CTRL_R :
  585.             Large_Monitor = ++Large_Monitor % 2;
  586.             CWK_Resize_Window();
  587.             break;
  588.             case CTRL_T :
  589.             task_step = ++task_step % 2;
  590.             break;
  591.         case ESC :
  592.             CWK_CLEANUP_MON(1);
  593.             break;
  594.         default :
  595.             break;
  596.         }
  597.         }
  598.  
  599. }
  600.  
  601. CWK_TIME_TASK()
  602. {
  603.     int iline;
  604.  
  605.     Run_Total_Time++; Run_Current_Time++; 
  606.     CWK_TASKS[current_task].Tot_Time++; CWK_TASKS[current_task].Cur_Time++;
  607.     busy_wait(step_rate);
  608.  
  609.     if ( ( Run_Total_Time % Time_To_Read_Key ) == 0 )
  610.     {
  611.         CWK_GET_KEY(-1);
  612.         if ( monitor_exec_time )
  613.         {
  614.             if ( ( Run_Total_Time % (Time_To_Read_Key * 10)) == 0 )
  615.                 CWK_REPORT_TIME( Run_Total_Time );
  616.         }
  617.     }
  618.     if ( ( Run_Total_Time % Exec_Report_Time ) == 0 )
  619.     {
  620.         if ( monitor_type == 2 )
  621.             CWK_Next_Pct_Rpt();
  622.         Run_Current_Time = 0;
  623.         for ( iline = 0; iline < MAX_TSKS; ++iline ) {
  624.             if ( CWK_TASKS[iline].TN != NULL ) 
  625.                 CWK_TASKS[iline].Cur_Time = 0;
  626.         }
  627.     }
  628. }
  629.  
  630. /***********************************************************************/
  631. /*    This routine turns off the monitoring windows.                   */
  632. /***********************************************************************/
  633.  
  634. CWK_STOP_MONITORING()
  635. {
  636.     int iline;
  637.  
  638.     /*  Stop the monitoring of the lines */
  639.     if ( monitor_type == 1 )
  640.     {
  641.     CWK_ERASE_ALL_MON_WIN();
  642.         for ( iline = 1; iline < MAX_TSKS; ++iline ) {
  643.         if ( CWK_TASKS[iline].TN != NULL ) 
  644.             CWK_TASKS[iline].MON->WON = -1;
  645.         }
  646.     }
  647.  
  648.     /*  Stop the monitoring of execution percentage */
  649.     else if ( monitor_type == 2 )
  650.     {
  651.         CWK_DEL_EXEC_PCT();
  652.     }
  653.  
  654.     monitor_type = 0;
  655. }
  656.  
  657. /***********************************************************************/
  658. /*   CWK_Next_Pct_Rpt reports the Pct of CPU time run since the last   */
  659. /*   report.                                                           */
  660. /***********************************************************************/
  661.  
  662. CWK_Next_Pct_Rpt()
  663. {
  664.     char msg[81], msg1[81];
  665.     int iline;
  666.     
  667.     CWK_EXEC_PCT();
  668.  
  669.     for ( iline = 0; iline < ( MAX_TSKS / 4 ); ++iline )
  670.     {
  671.         msg[0] = '\0';
  672.         if ( CWK_TASKS[(4*iline)+1].TN != NULL )
  673.         {
  674.             sprintf( msg, "%2.2d  %-7.7s %1.1c %3.2f ", 
  675.                 (4*iline)+1, CWK_TASKS[(4*iline)+1].TN, 
  676.                 CWK_TASKS[(4*iline)+1].ST, 
  677.                 (float) CWK_TASKS[(4*iline)+1].Cur_Time /
  678.                     (float)Run_Current_Time );
  679.         }
  680.         if ( CWK_TASKS[(4*iline)+2].TN != NULL )
  681.         {
  682.             sprintf( msg1, "%2.2d  %-7.7s %1.1c %3.2f ", 
  683.                 (4*iline)+2, CWK_TASKS[(4*iline)+2].TN, 
  684.                 CWK_TASKS[(4*iline)+2].ST, 
  685.                 (float) CWK_TASKS[(4*iline)+2].Cur_Time /
  686.                     (float)Run_Current_Time );
  687.         strcat( msg, msg1 );
  688.         }
  689.         if ( CWK_TASKS[(4*iline)+3].TN != NULL )
  690.         {
  691.             sprintf( msg1, "%2.2d  %-7.7s %1.1c %3.2f ", 
  692.                 (4*iline)+3, CWK_TASKS[(4*iline)+3].TN, 
  693.                 CWK_TASKS[(4*iline)+3].ST, 
  694.                 (float) CWK_TASKS[(4*iline)+3].Cur_Time /
  695.                     (float)Run_Current_Time );
  696.         strcat( msg, msg1 );
  697.         }
  698.         if ( CWK_TASKS[(4*iline)+4].TN != NULL )
  699.         {
  700.             sprintf( msg1, "%2.2d  %-7.7s %1.1c %3.2f ", 
  701.                 (4*iline)+4, CWK_TASKS[(4*iline)+4].TN, 
  702.                 CWK_TASKS[(4*iline)+4].ST, 
  703.                 (float) CWK_TASKS[(4*iline)+4].Cur_Time /
  704.                     (float)Run_Current_Time );
  705.         strcat( msg, msg1 );
  706.         }
  707.             CWK_EXEC_PRINT_LINE( iline+2, msg );
  708.     }
  709. }
  710.  
  711. /***********************************************************************/
  712. /*   CWK_Exception_Raised reports exceptions to the screen when running*/
  713. /*   the monitor.                               */
  714. /***********************************************************************/
  715.  
  716. CWK_Exception_Raised( task_id, msg )
  717. int task_id;
  718. char *msg;
  719. {
  720.     if ( ! task_monitor )
  721.     {
  722.         CWK_Report_Exception( "main", msg );
  723.         return;
  724.     }
  725.     else
  726.     {
  727.         if ( task_id == 0 )
  728.         task_id = current_task;
  729.         if ( exception_trace )
  730.         CWK_Report_Exception( CWK_TASKS[task_id].TN, msg );
  731.     }
  732. }
  733.